﻿@using GMS.Core.Config
@using GMS.Web.Admin.Common
@{
    var adminMenuConfig = CachedConfigContext.Current.AdminMenuConfig;
    var permissions = AdminUserContext.Current.LoginInfo.BusinessPermissionList.Select(p=>p.ToString());
}
<div class="page-sidebar nav-collapse collapse">
	<!-- BEGIN SIDEBAR MENU -->        	
	<ul>
		<li>
			<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
			<div class="sidebar-toggler hidden-phone"><h3 style="margin-left:-160px; line-height:23px;  color:#666; ">GMS功能菜单</h3></div>
			<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
		</li>
		<li>
			<!-- BEGIN RESPONSIVE QUICK SEARCH FORM -->
			<form class="sidebar-search dn">
				<div class="input-box">
					<a href="javascript:;" class="remove"></a>
					<input type="text" placeholder="Search..." />				
					<input type="button" class="submit" value=" " />
				</div>
			</form>
			<!-- END RESPONSIVE QUICK SEARCH FORM -->
		</li>
        @foreach (var group in adminMenuConfig.AdminMenuGroups)
        {
            if (!string.IsNullOrEmpty(group.Permission) && !permissions.Contains(group.Permission))
            {
                continue;
            }

            var menus = group.AdminMenuArray.Where(m => string.IsNullOrEmpty(m.Permission) || permissions.Contains(m.Permission));
            var hasSub = menus.Count() > 0;

            if (!hasSub && string.IsNullOrEmpty(group.Url))
            {
                continue;
            }
            
            <li class="@(hasSub?"has-sub":string.Empty)">
			    <a href="@(hasSub ? "javascript:;" : group.Url)" title="@group.Info">
			    <i class="@group.Icon"></i> 
			    <span class="title">@group.Name</span>
                @if (hasSub)
                {
                    <span class='arrow'></span>
                }
			    </a>
                @if (hasSub)
                {
                    <ul class="sub">
                    @foreach (var menu in menus)
                    {
				        <li ><a href="@menu.Url" title="@menu.Info">@menu.Name</a></li>
                    }
                    </ul>
                }
		    </li>
        }

        @*
		<li class="start ">
			<a href="#">
			<i class="icon-home"></i> 
			<span class="title">管理首页</span>
			</a>
		</li>
		<li class="has-sub ">
			<a href="javascript:;">
			<i class="icon-bookmark-empty"></i> 
			<span class="title">界面相关</span>
			<span class="arrow "></span>
			</a>
			<ul class="sub">
				<li ><a href="ui_general.html">通用</a></li>
				<li ><a href="ui_buttons.html">按钮</a></li>
				<li ><a href="ui_tabs_accordions.html">选项卡</a></li>
				<li ><a href="ui_sliders.html">滑动条</a></li>
				<li ><a href="ui_tiles.html">打点</a></li>
				<li ><a href="ui_typography.html">Typography</a></li>
				<li ><a href="ui_tree.html">树控件</a></li>
				<li ><a href="ui_nestable.html">Nestable List</a></li>
			</ul>
		</li>
		<li class="has-sub ">
			<a href="javascript:;">
			<i class="icon-table"></i> 
			<span class="title">Form Stuff</span>
			<span class="arrow "></span>
			</a>
			<ul class="sub">
				<li ><a href="form_layout.html">Form Layouts</a></li>
				<li ><a href="form_samples.html">Advance Form Samples</a></li>
				<li ><a href="form_component.html">Form Components</a></li>
				<li ><a href="form_wizard.html">Form Wizard</a></li>
				<li ><a href="form_validation.html">Form Validation</a></li>
				<li ><a href="form_fileupload.html">Multiple File Upload</a></li>
				<li ><a href="form_dropzone.html">Dropzone File Upload</a></li>
			</ul>
		</li>
		<li class="has-sub ">
			<a href="javascript:;">
			<i class="icon-table"></i> 
			<span class="title">Data Tables</span>
			<span class="arrow "></span>
			</a>
			<ul class="sub">
				<li ><a href="@Url.Action("Product", "Home")">测试菜单一</a></li>
				<li ><a href="table_managed.html">Managed Tables</a></li>
				<li ><a href="table_editable.html">Editable Tables</a></li>
			</ul>
		</li>
		<li class="has-sub ">
			<a href="javascript:;">
			<i class="icon-th-list"></i> 
			<span class="title">Portlets</span>
			<span class="arrow "></span>
			</a>
			<ul class="sub">
				<li ><a href="portlet_general.html">General Portlets</a></li>
				<li ><a href="@Url.Action("Category","Home")">测试菜单二</a></li>
			</ul>
		</li>
		<li class="has-sub ">
			<a href="javascript:;">
			<i class="icon-map-marker"></i> 
			<span class="title">Maps</span>
			<span class="arrow "></span>
			</a>
			<ul class="sub">
				<li ><a href="maps_google.html">Google Maps</a></li>
				<li ><a href="maps_vector.html">Vector Maps</a></li>
			</ul>
		</li>
		<li class="">
			<a href="charts.html">
			<i class="icon-bar-chart"></i> 
			<span class="title">Visual Charts</span>
			</a>
		</li>
		<li class="">
			<a href="calendar.html">
			<i class="icon-calendar"></i> 
			<span class="title">Calendar</span>
			</a>
		</li>
		<li class="">
			<a href="gallery.html">
			<i class="icon-camera"></i> 
			<span class="title">Gallery</span>
			</a>
		</li>
		<li class="has-sub ">
			<a href="javascript:;">
			<i class="icon-briefcase"></i> 
			<span class="title">Extra</span>
			<span class="arrow "></span>
			</a>
			<ul class="sub">
				<li ><a href="extra_profile.html">User Profile</a></li>
				<li ><a href="extra_faq.html">FAQ</a></li>
				<li ><a href="extra_search.html">Search Results</a></li>
				<li ><a href="extra_invoice.html">Invoice</a></li>
				<li ><a href="extra_pricing_table.html">Pricing Tables</a></li>
				<li ><a href="extra_404.html">404 Page</a></li>
				<li ><a href="extra_500.html">500 Page</a></li>
				<li ><a href="extra_blank.html">Blank Page</a></li>
				<li ><a href="extra_full_width.html">Full Width Page</a></li>
			</ul>
		</li>
		<li class="">
			<a href="login.html">
			<i class="icon-user"></i> 
			<span class="title">Login Page</span>
			</a>
		</li>
        *@
	</ul>
	<!-- END SIDEBAR MENU -->
</div>